function addProblem(CertusFormAjax,$scope) {

    //所属公司
    CertusFormAjax.ajax("companyListByViewCode",{},function (response) {
        $scope.comp = JSON.parse(response.data);
    });

    this.changetp = function () {
        CertusFormAjax.ajax("findProByType",{"proType":$("#proType").val()},function (response) {
            $scope.prorlist = response.data;
        });
    };

    this.getProMg = function(){
        CertusFormAjax.ajax("findMg",{"proId":$("#rproId").val()},function (response) {
            $scope.userName = response.data.userName;
            $scope.userId = response.data.userId;
        });
    };

    CertusFormAjax.ajax("findSpUserList",{},function (response) {
        var nhlTeams = [];
        var data = response.data;
        for (var i=0;i<data.length;i++){
            var arr={};
            arr.name=data[i].userName+"["+data[i].positonName+"]";
            arr.id = data[i].userId;
            nhlTeams.push(arr);
        }
        //自动补全
        var nhl = $.map(nhlTeams, function (obj) {
            return {
                value: obj.name,
                data: { category: obj.id }
            };
        });
        // Initialize autocomplete with local lookup:
        $('#autocomplete').devbridgeAutocomplete({
            lookup: nhl,
            minChars: 1,
            onSelect: function (suggestion) {
                $("#userId").val(suggestion.data.category);
            },
            showNoSuggestionNotice: true,
            noSuggestionNotice: 'Sorry, no matching results'
        });
    });

    CertusFormAjax.ajax("findSeProList",{},function(response){
        var nhlTeams = [];
        var data = response.data;
        for (var i=0;i<data.length;i++){
            var arr={};
            arr.name=data[i].proName;
            arr.id = data[i].id;
            nhlTeams.push(arr);
        }
        //自动补全
        var nhl = $.map(nhlTeams, function (obj) {
            return {
                value: obj.name,
                data: { category: obj.id }
            };
        });
        // Initialize autocomplete with local lookup:
        $('#proName').devbridgeAutocomplete({
            lookup: nhl,
            minChars: 1,
            onSelect: function (suggestion) {
                $("#proId").val(suggestion.data.category);
            },
            showNoSuggestionNotice: true,
            noSuggestionNotice: 'Sorry, no matching results'
        });
    });

    this.getDept = function () {
        CertusFormAjax.ajax("deptList",{companyCode:$("#companys").val()},function (response) {
            $scope.dept = JSON.parse(response.data);
        });
    }


    var fileId = "";
    $(".toRegu").on('click',function () {
        fileUpload($scope,function (res){
            fileId = res.data;
        },null,CertusFormAjax);
    })

    $(".submit").on('click',function () {
        if (!certusValidateNotnull()){
            return;
        }
        if ($("#prbLevel").val()==""){
            layer.msg("请选择项目优先级！");
            return
        }
        var arr =$("form").serializeArray();
        var data = {};
        for (var i=0;i<arr.length;i++){
            data[arr[i].name] = arr[i].value;
        };
        data.fileUrl = fileId;
        CertusFormAjax.ajax("toAddProblem",{"data":JSON.stringify(data)},function(response){
            layer.msg("提交成功");
            window.history.back();
        });
    })
}

//文件上传统一字段
function showfile() {
    $(".hidefile").show();
    $("#isUpload").val(1);
}
hidefile();
function hidefile() {
    $(".hidefile").hide();
    $("#isUpload").val(0);
}